home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 25
/
Mac Magazin and MacEasy Magazine CD - Issue 25.iso
/
Grafik & Text
/
Alpha
/
Tcl
/
UserCode
/
parray.tcl
< prev
next >
Wrap
Text File
|
1996-08-15
|
1KB
|
33 lines
# parray:
# Print the contents of a global array on stdout.
#
# $Header: /rel/cvsfiles/devo/tcl/library/parray.tcl,v 1.2 1992/12/23 15:40:10 zoo Exp $ SPRITE (Berkeley)
#
# Copyright 1991 Regents of the University of California
# Permission to use, copy, modify, and distribute this
# software and its documentation for any purpose and without
# fee is hereby granted, provided that this copyright
# notice appears in all copies. The University of California
# makes no representations about the suitability of this
# software for any purpose. It is provided "as is" without
# express or implied warranty.
#
proc parray a {
upvar 1 $a array
if [catch {array size array}] {
error "\"$a\" isn't an array"
}
set maxl 0
foreach name [lsort [array names array]] {
if {[string length $name] > $maxl} {
set maxl [string length $name]
}
}
set maxl [expr {$maxl + [string length $a] + 2}]
foreach name [lsort [array names array]] {
set nameString [format %s(%s) $a $name]
insertText [format "%-*s = %s" $maxl $nameString $array($name)]
}
}